package chunzhao.Jun_20;

/**
 * @Classname QuickSort
 * @Description TODO
 * @Date 2024/1/20 15:36
 * @Created by ZHL17
 */
public class QuickSort {
    public static void main(String[] args) {

        int[] nums = {12,3,45,68,19,75,10};
        quickSort(nums, 0, nums.length - 1);
        for (int num : nums) {
            System.out.print(num);
        }


    }
    public static void quickSort(int[] nums, int left, int right) {
        if (left >= right) return ;
        int l = left;
        int r = right;
        while(l < r) {
            while (l < r && nums[r] >= nums[left]) r--;
            while (l < r && nums[l] <= nums[left]) l++;
            swap(nums, l,r);
        }
        swap(nums, l,left);
        quickSort(nums, left, l - 1);
        quickSort(nums, l + 1, right);
    }
    public static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}